{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0]\n",
      "[0.0, 0.47619047619047616, 0.9523809523809523, 1.4285714285714284, 1.9047619047619047, 2.380952380952381, 2.8571428571428568, 3.333333333333333, 3.8095238095238093, 4.285714285714286, 4.761904761904762, 5.238095238095238, 5.7142857142857135, 6.19047619047619, 6.666666666666666, 7.142857142857142, 7.619047619047619, 8.095238095238095, 8.571428571428571, 9.047619047619047, 9.523809523809524]\n"
     ]
    }
   ],
   "source": [
    "def linespace(start, stop, num=50, endpoint=True):\n",
    "    if num < 2:\n",
    "        raise ValueError(\"Number of samples must be at least 2\")\n",
    "    if endpoint:\n",
    "        step = (stop - start) / (num - 1)\n",
    "        return [start+ i* step for i in range(num)]\n",
    "    else:\n",
    "        step = (stop - start) / num\n",
    "        return [start + i * step for i in range(num)]\n",
    "\n",
    "start = 0\n",
    "stop = 10\n",
    "num = 21\n",
    "print(linespace(start, stop, num))\n",
    "\n",
    "print(linespace(start, stop, num, endpoint=False))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
